using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Configuration;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class DataSetPage : System.Web.UI.Page
{
    string connectionString =
    WebConfigurationManager.ConnectionStrings[
    "RCVDB2000"].ConnectionString;
    SqlConnection sqlConnection;
    SqlCommand sqlCommand;
    SqlDataAdapter sqlDataAdapter;
    
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            LoadData(); 
        }
    }
    void LoadData()
    {        
        sqlConnection = new SqlConnection();
        sqlConnection.ConnectionString =
        connectionString;
        try
        {
            sqlConnection.Open();
            sqlCommand = new SqlCommand();
            sqlCommand.CommandText =
            "select * from tblJobCategories "
            + " select * from tblJobIndustries "+
            " select * from tblProvinces";
            sqlCommand.Connection = sqlConnection;
            sqlCommand.CommandType = CommandType.Text;
            sqlDataAdapter
            = new SqlDataAdapter(sqlCommand);
            DataSet dataSet = new DataSet();
            sqlDataAdapter.Fill(dataSet);
            FillDataSetToDropDonList(dataSet);
            sqlCommand.Dispose();
            sqlConnection.Close();
        }
        catch (Exception ex)
        {
            Literal1.Text += "Failed:" + ex.Message;
        }
        sqlConnection.Dispose(); 
    }
    
    void FillDataSetToDropDonList(DataSet dataSet)
    {
        DropDownList1.DataSource = dataSet.Tables[0];
        DropDownList1.DataTextField = "JobCategoryName";
        DropDownList1.DataValueField = "JobCategoryID";
        DropDownList1.DataBind();

        DropDownList2.DataSource = dataSet.Tables[1];
        DropDownList2.DataTextField = "JobIndustryName";
        DropDownList2.DataValueField = "JobIndustryID";
        DropDownList2.DataBind();
        
        DropDownList3.DataSource = dataSet.Tables[2];
        DropDownList3.DataTextField = "ProvinceName";
        DropDownList3.DataValueField = "ProvinceID";
        DropDownList3.DataBind();
    }
}
